package content.views;
import content.views.contact.ContactItem;
import feffects.easing.Quad;
import params.GlobalParams;
import tools.ASprite;
import tools.BoundProvider;

/**
 * ...
 * @author PRASS
 */

class Contact extends BaseView
{
	private var _contactContainer 	: ASprite;
	private var _title 				: ASprite;
	
	private var _itemz				: Array<ContactItem>;
	
	private var _mail 				: ContactItem;
	private var _twitter			: ContactItem;
	private var _linkedin			: ContactItem;
	
	public function new( id : String, tpl : String ) 
	{
		super(id, tpl);
		
		dom.css("background-image", "url(" + GlobalParams.BG_CONTACT + ")");
		_itemz = new Array<ContactItem>();
	}
	
	override public function build():Void 
	{
		_contactContainer = new ASprite( new JQuery("#contact #container") );
		_title = new ASprite( new JQuery("#contactTitle"));
		_title.setAlpha(0);
		
		_mail 		= new ContactItem( new JQuery("#mail"), "mail" );
		_twitter 	= new ContactItem( new JQuery("#twitter"), "twitter"  );
		_linkedin 	= new ContactItem( new JQuery("#linkedin"), "linkedin"  );
	}
	
	override public function play():Void 
	{
		super.play();
		
		_mail.setAlpha(0);
		_twitter.setAlpha(0);
		_linkedin.setAlpha(0);
		
		_title.tween(0, _title.setAlpha, 1, 600, Quad.easeInOut, null, 200);
		
		_mail.display();
		_twitter.display(100);
		_linkedin.display(200);
	}
	
	override public function hide():Void 
	{
		_title.tween(_title.getAlpha(), _title.setAlpha, 0, 300, Quad.easeOut);
		
		_mail.hide(300);
		_twitter.hide(150);
		_linkedin.hide();
	}
	
	override public function resize(_w:Int, _h:Int):Void 
	{
		if ( _title == null ) return;
		
		super.resize(_w, _h);
		
		var _x : Float = 216;
		var _y : Float = 145;
		
		_title.setX( cast _x );
		_title.setY( cast _y - 50 );
		
		_contactContainer.setX( cast _x );
		_contactContainer.setY( cast _y );
		
		_mail.resize();
		_twitter.resize();
		_linkedin.resize();
	}
}